package com.itheima.mapper;

import com.itheima.entity.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrderMapper {
    @Insert("insert into orders values(#{id},#{number},#{status},#{userId},#{addressBookId},#{orderTime}," +
            "#{checkoutTime},#{payMethod},#{amount},#{remark},#{phone},#{address},#{userName},#{consignee})")
    void save(Orders orders);

    List<Orders> findAllOrNumberOrOrderTime(@Param("number") String number, @Param("beginTime") String beginTime, @Param("endTime") String endTime);

    @Select("select * from `orders` where user_id=#{userId} order by order_time desc")
    List<Orders> findAll(Long userId );
    @Select("select count(*) from orders where user_id=#{userId}  ")
    Long count(Long userId);

}
